<?php

namespace app\model\common;

class PaymentImplementers
{
    public static function sandAlipayAppParams($order_sn)
    {
        //获取参数
        $configs = [];//data_get(self::getConfigs(), 'sandpay.alipay', []);
        //获取订单支付信息
//        $data = self::orderData($order_sn);
        $ip = '183.226.89.117';
        $ip = str_ireplace('.', '_', $ip);//测试环境
        //整理支付参数
        $order = array_merge(data_get($configs, 'queryData', []), [
            'mer_no'=> '665107000014977',//商户编号
            'meta_option' => rawurlencode('[{"s":"Android","n":"","id":"","sc":""},{"s":"IOS","n":"","id":"","sc":""}]'),

            'mer_order_no' => time(),//$order_sn,//$data['out_trade_no'],
//            'create_time' => auto_datetime('YmdHis'),
//            'expire_time' => auto_datetime('YmdHis', (time()+7200)),
            'create_time' => date('YmdHis'),
            'expire_time' => date('YmdHis', (time()+7200)),
            'order_amt' => (string)'0.01',//$data['total_amount'],
            'create_ip' => str_replace('.', '_', $ip),//str_replace('.', '_', $data['ip']),
            'goods_name' => 'zhu',//$data['subject'],
            'product_code' => '01020002',
        ]);
        //生成签名
        $order['sign'] = SandPayImplementers::sign($order);
        //循环内容处理
        foreach (Arr::only($order, ['goods_name', 'notify_url', 'return_url', 'pay_extra', 'meta_option', 'sign']) as $k => $value) {
            //整理信息
            $order[$k] = urlencode($value);
        }
        $url = 'https://cash.sandgate.cn/h5/';
        //整理链接
//        $query_link = data_get($configs, 'link.prefix', '').'?'.SandPayImplementers::urlParams($order).data_get($configs, 'link.suffix', '');
        $query_link = $url . '?' . SandPayImplementers::urlParams($order) . '#/hippoh5';

//        'https://cash.sandgate.cn/h5/#/hippoh5'
        //返回链接
        return ['sand_query_link' => $query_link];
    }
}